/* 
 * Copyright (c) 2012, Fromentin Xavier, Schnell Michaël, Dervin Cyrielle, Brabant Quentin
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *      * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *      * The names of its contributors may not be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Fromentin Xavier, Schnell Michaël, Dervin Cyrielle OR Brabant Quentin 
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package kameleon.plugin;

import java.io.Serializable;

/**
 * Class containing informations about the installed plug-ins.
 * 
 * <p>This class contains the following informations about the plug-ins :
 * <ul>
 * <li>unique identifier for all installed plug-ins
 * <li>type of this plug-in (analyzer or generator)
 * <li>name of the jar
 * <li>the complete name of the "main" class of the plug-in
 * <li>list of the known extensions
 * <li>name of the format used by this plug-in
 * <li>list of the supported options for this plug-in
 * </ul>
 * The "main" class of the plug-in is the class which extends {@code Analyzer} 
 * (or {@code Generator} depending on the type of plug-in).
 *
 * @author		Fromentin Xavier, Schnell Michaël
 * @version		1.0
 * 
 * @see			PlugIn
 */
public class PlugInInfo implements Serializable {

	/**
	 * Needed to serialize this class.
	 * 
	 * @see		java.io.Serializable
	 */
	private static final long serialVersionUID = 7326515690125463076L;

	/**
	 * Unique identifier
	 */
	protected String id ;

	/**
	 * Indicates the type of this plug-in
	 */
	protected boolean isAnalyzer ;

	/**
	 * Name of the jar without the .jar extension (not the path)
	 */
	protected String jarName ;

	/**
	 * Name of the main class for the plug-in (class which extends PlugIn)
	 */
	protected String mainClass ;

	/**
	 * List of the common extensions for this format
	 */
	protected String[] extensions ;

	/**
	 * Name of the format used by this plug-in
	 */
	protected String formatName ;

	/**
	 * List of the supported options.
	 */
	protected SupportedOptions options ;

	/**
	 * Builds a new instance with the given values.
	 * 
	 * @param	id
	 * 			unique identifier of this instance
	 * 
	 * @param	isAnalyzer
	 * 			indicates whether this plug-in is an analyzer
	 * 
	 * @param	jarName
	 * 			name of the jar
	 * 
	 * @param	mainClass
	 * 			complete name of the "main" class of this plug-in
	 * 
	 * @param	extensions
	 * 			list of the common extensions for this format
	 * 
	 * @param	formatName
	 * 			name of the format used by this plug-in
	 * 
	 * @param	options
	 * 			list of the supported options
	 */
	public PlugInInfo(String id, boolean isAnalyzer, 
			String jarName, String mainClass, 
			String[] extensions, String formatName, 
			SupportedOptions options) {
		super() ;
		this.id = id ;
		this.isAnalyzer = isAnalyzer ;
		this.jarName = jarName ;
		this.mainClass = mainClass ;
		this.extensions = extensions ;
		this.formatName = formatName ;
		this.options = options ;
	}// PlugInInfo(String, boolean, String, String, String[], String, SupportedOptions)

	/**
	 * Return the unique identifier of the plug-in.
	 * 
	 * @return 	The unique identifier
	 */
	public String getId() {
		return this.id ;
	}// getId()

	/**
	 * Indicates whether this plug-in is an analyzer.
	 * 
	 * @return	{@code true} if this plug-in is an analyzer, {@code false} otherwise
	 */
	public boolean isAnalyzer() {
		return this.isAnalyzer ;
	}// isAnalyzer()

	/**
	 * Returns the name of the jar for this plug-in.
	 * 
	 * @return	Name of the jar
	 */
	public String getJarName() {
		return this.jarName ;
	}// getJarName()

	/**
	 * Returns the (complete) name of the main class for the plug-in. 
	 * The "main" class of the plug-in is the class which extends {@code Analyzer} 
	 * (or {@code Generator} depending on the type of plug-in).
	 * 
	 * @return 	Name of the main class for the plug-in.
	 */
	public String getPlugInClass() {
		return this.mainClass ;
	}// getPlugInClass()

	/**
	 * Returns the list of common extensions for this plug-in.
	 * 
	 * @return	List of common extensions
	 */
	public String[] getExtensions() {
		return this.extensions ;
	}// getExtensions()

	/**
	 * Returns the name of the format used by this plug-in.
	 * 
	 * @return	Name of the format used by this plug-in
	 */
	public String getFormatName() {
		return this.formatName ;
	}// getFormatName()

	/**
	 * Returns the list of the supported options.
	 * 
	 * @return	List of the supported options as a {@code SupportedOptions} instance
	 */
	public SupportedOptions getSupportedOptions() {
		return this.options ;
	}// getSupportedOptions()

	/**
	 *	Indicates whether some other object is "equal to" this one.
	 *
	 *	<p>Two instances of {@code PlugInInfo} are considered to be "equal"
	 *	if their identifiers are the same.
	 */
	@Override
	public boolean equals(Object obj) {
		if ((obj == null) || !(obj instanceof PlugInInfo)) {
			return false ;
		}// if
		PlugInInfo other = (PlugInInfo) obj ;
		return this.id.equals(other.id) ;
	}// equals(Object)

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		return this.id.hashCode() ;
	}// hashCode()

}// class PlugInInfo